package com.sap.sap_mangers.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 动态表的信息 --> 自定义的构造器参数对应DynamicMapper的getAllContext方法
 *
 * @author 谢添
 * @date 2022/8/3 20:59
 */
@NoArgsConstructor
@Data
@AllArgsConstructor
public class DynamicMessage {
    Integer year;
    Integer order;
    Integer week;

    String username;

    public DynamicMessage(List<String> context) {
        year = Integer.parseInt(context.get(0));
        order = Integer.parseInt(context.get(1));
        week = Integer.parseInt(context.get(2));
    }

    public DynamicMessage(Integer year, Integer order, Integer week) {
        this.year = year;
        this.order = order;
        this.week = week;
    }

    public void setDefaultTimeByDynamicTable(DynamicMessage dynamicMessage) {
        if (year == null || year <= 0) {
            year = dynamicMessage.getYear();
        }
        if (week == null || week <= 0) {
            week = dynamicMessage.getWeek();
        }
        if (order == null || order <= 0) {
            order = dynamicMessage.getOrder();
        }
    }
}
